﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1Input;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_AddDonViTinh : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CboDVT")]
        private ComboBox _CboDVT;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("CmdOK")]
        private Button _CmdOK;
        [AccessedThroughProperty("GroupBox1")]
        private GroupBox _GroupBox1;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label10")]
        private Label _Label10;
        [AccessedThroughProperty("Label13")]
        private Label _Label13;
        [AccessedThroughProperty("TxtDienGiai")]
        private TextBox _TxtDienGiai;
        [AccessedThroughProperty("txtHeSo")]
        private C1NumericEdit _txtHeSo;
        private string cFrmFormat;
        public string cFrmKhoa;
        public string cFrmKhoaHangHoa;
        private IContainer components;
        private clsDMChiTietDonViTinh objCTDVT;
        private DataView pData;

        public Frm_AddDonViTinh()
        {
            base.FormClosing += new FormClosingEventHandler(this.Frm_AddDonViTinh_FormClosing);
            base.Load += new EventHandler(this.Frm_AddDonViTinh_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.objCTDVT = new clsDMChiTietDonViTinh();
            this.cFrmKhoa = "";
            this.cFrmKhoaHangHoa = "";
            this.InitializeComponent();
        }

        public bool CheckIvalidRows()
        {
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboDVT.SelectedValue), "", modGeneral.TypeOfValue.Nothing).ToString() == "")
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn phải nhập đơn vị t\x00ednh!", ""));
                this.CboDVT.Focus();
            }
            if (this.objCTDVT.isDupplicateCode(this.cFrmKhoa, this.cFrmKhoaHangHoa, LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboDVT.SelectedValue), "", modGeneral.TypeOfValue.Nothing).ToString()))
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Kho\x00e1 n\x00e0y đ\x00e3 tồn tại. Xin vui l\x00f2ng chọn lại kho\x00e1 kh\x00e1c!", ""));
                this.CboDVT.Focus();
                return false;
            }
            return true;
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            if (this.CheckIvalidRows())
            {
                this.objCTDVT.Khoa = this.cFrmKhoa;
                this.objCTDVT.KhoaHangHoa = this.cFrmKhoaHangHoa;
                this.objCTDVT.KhoaDonViTinh = Conversions.ToString(this.CboDVT.SelectedValue);
                this.objCTDVT.HeSo = Conversions.ToDouble(this.txtHeSo.Value);
                this.objCTDVT.DienGiai = this.TxtDienGiai.Text;
                if (this.objCTDVT.Save())
                {
                    this.Dispose();
                }
            }
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        public void FormatNumber()
        {
            LVYModule.advFormatNumber(this.txtHeSo, this.cFrmFormat);
        }

        private void Frm_AddDonViTinh_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.cFrmKhoa = "";
        }

        private void Frm_AddDonViTinh_Load(object sender, EventArgs e)
        {
            BuildComboModule.BuildCombo(this.CboDVT, modGeneral.ListDanhMuc.DonViTinh, false, "", "");
            this.SetLanguage();
            if (this.cFrmKhoa.Trim() != "")
            {
                this.ShowData(this.cFrmKhoa);
            }
            else
            {
                this.CboDVT.SelectedValue = "";
                this.txtHeSo.Value = 0;
                this.TxtDienGiai.Text = "";
                this.cFrmKhoa = modGeneral.CreatKey("DM_ChiTietDonViTinh", 10, "");
            }
            this.cFrmFormat = "##,##0.####";
            this.FormatNumber();
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_AddDonViTinh));
            this.GroupBox1 = new GroupBox();
            this.TxtDienGiai = new TextBox();
            this.Label1 = new Label();
            this.Label13 = new Label();
            this.Label10 = new Label();
            this.CboDVT = new ComboBox();
            this.CmdCancel = new Button();
            this.CmdOK = new Button();
            this.txtHeSo = new C1NumericEdit();
            this.GroupBox1.SuspendLayout();
            ((ISupportInitialize) this.txtHeSo).BeginInit();
            this.SuspendLayout();
            this.GroupBox1.BackColor = Color.Transparent;
            this.GroupBox1.Controls.Add(this.txtHeSo);
            this.GroupBox1.Controls.Add(this.TxtDienGiai);
            this.GroupBox1.Controls.Add(this.Label1);
            this.GroupBox1.Controls.Add(this.Label13);
            this.GroupBox1.Controls.Add(this.Label10);
            this.GroupBox1.Controls.Add(this.CboDVT);
            Point point = new Point(4, 5);
            this.GroupBox1.Location = point;
            this.GroupBox1.Name = "GroupBox1";
            Size size = new Size(0x149, 0x7e);
            this.GroupBox1.Size = size;
            this.GroupBox1.TabIndex = 6;
            this.GroupBox1.TabStop = false;
            this.GroupBox1.Text = "Chọn đơn vị t\x00ednh";
            point = new Point(0x5f, 0x58);
            this.TxtDienGiai.Location = point;
            this.TxtDienGiai.Name = "TxtDienGiai";
            size = new Size(0xe2, 20);
            this.TxtDienGiai.Size = size;
            this.TxtDienGiai.TabIndex = 2;
            this.Label1.AutoSize = true;
            point = new Point(0x11, 0x5b);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x30, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 50;
            this.Label1.Text = "Diễn giải";
            this.Label13.AutoSize = true;
            point = new Point(0x11, 0x3d);
            this.Label13.Location = point;
            this.Label13.Name = "Label13";
            size = new Size(0x23, 13);
            this.Label13.Size = size;
            this.Label13.TabIndex = 0x31;
            this.Label13.Text = "Hệ số";
            this.Label10.AutoSize = true;
            point = new Point(0x11, 0x20);
            this.Label10.Location = point;
            this.Label10.Name = "Label10";
            size = new Size(60, 13);
            this.Label10.Size = size;
            this.Label10.TabIndex = 0x30;
            this.Label10.Text = "Đơn vị t\x00ednh";
            this.CboDVT.DropDownStyle = ComboBoxStyle.DropDownList;
            this.CboDVT.FormattingEnabled = true;
            point = new Point(0x5f, 0x1d);
            this.CboDVT.Location = point;
            this.CboDVT.Name = "CboDVT";
            size = new Size(0xe2, 0x15);
            this.CboDVT.Size = size;
            this.CboDVT.TabIndex = 0;
            this.CmdCancel.DialogResult = DialogResult.Cancel;
            this.CmdCancel.Image = (Image) manager.GetObject("CmdCancel.Image");
            this.CmdCancel.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0xfe, 0x89);
            this.CmdCancel.Location = point;
            this.CmdCancel.Name = "CmdCancel";
            size = new Size(0x4f, 0x18);
            this.CmdCancel.Size = size;
            this.CmdCancel.TabIndex = 4;
            this.CmdCancel.Text = "&Tho\x00e1t";
            this.CmdCancel.UseVisualStyleBackColor = true;
            this.CmdOK.Image = (Image) manager.GetObject("CmdOK.Image");
            this.CmdOK.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0xab, 0x89);
            this.CmdOK.Location = point;
            this.CmdOK.Name = "CmdOK";
            size = new Size(0x4e, 0x18);
            this.CmdOK.Size = size;
            this.CmdOK.TabIndex = 3;
            this.CmdOK.Text = "&Chọn";
            this.CmdOK.UseVisualStyleBackColor = true;
            this.txtHeSo.BorderStyle = BorderStyle.FixedSingle;
            this.txtHeSo.CustomFormat = "##,###,##0";
            this.txtHeSo.FormatType = FormatTypeEnum.CustomFormat;
            point = new Point(0x5f, 0x3a);
            this.txtHeSo.Location = point;
            this.txtHeSo.Name = "txtHeSo";
            Padding padding = new Padding(1);
            this.txtHeSo.Padding = padding;
            size = new Size(0x4c, 20);
            this.txtHeSo.Size = size;
            this.txtHeSo.TabIndex = 0x34;
            this.txtHeSo.Tag = null;
            this.txtHeSo.VisibleButtons = DropDownControlButtonFlags.DropDown;
            this.txtHeSo.VisualStyle = VisualStyle.Office2007Blue;
            this.txtHeSo.VisualStyleBaseStyle = VisualStyle.Office2007Blue;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            this.BackgroundImage = ACCOUNTING.My.Resources.Resources.background;
            size = new Size(0x151, 0xa5);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.CmdCancel);
            this.Controls.Add(this.CmdOK);
            this.Controls.Add(this.GroupBox1);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.Name = "Frm_AddDonViTinh";
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "THEM DON VI TINH";
            this.GroupBox1.ResumeLayout(false);
            this.GroupBox1.PerformLayout();
            ((ISupportInitialize) this.txtHeSo).EndInit();
            this.ResumeLayout(false);
        }

        public void SetLanguage()
        {
            this.CmdOK.Text = modGeneral.Tranlated(this.CmdOK.Text, "");
            this.CmdCancel.Text = modGeneral.Tranlated(this.CmdCancel.Text, "");
            this.Label10.Text = modGeneral.Tranlated(this.Label10.Text, "");
            this.Label13.Text = modGeneral.Tranlated(this.Label13.Text, "");
            this.Label1.Text = modGeneral.Tranlated(this.Label1.Text, "");
        }

        public void ShowData(string pKhoa)
        {
            if (LVYModule.ReturnIfNull(this.cFrmKhoaHangHoa, "", modGeneral.TypeOfValue.Nothing).ToString().Trim() != "")
            {
                clsDMChiTietDonViTinh objCTDVT = this.objCTDVT;
                if (objCTDVT.Load(pKhoa))
                {
                    this.CboDVT.SelectedValue = objCTDVT.KhoaDonViTinh;
                    this.TxtDienGiai.Text = objCTDVT.DienGiai;
                    this.txtHeSo.Value = objCTDVT.HeSo;
                    objCTDVT = null;
                }
            }
        }

        private void TxtHeso_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                this.SelectNextControl(this.txtHeSo, true, true, true, true);
            }
        }

        private void TxtHeso_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Strings.InStr("0123456789", e.KeyChar.ToString(), CompareMethod.Binary) == 0)
            {
                e.KeyChar = '\0';
            }
        }

        internal virtual ComboBox CboDVT
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboDVT;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CboDVT = value;
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CmdCancel = value;
            }
        }

        internal virtual Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        internal virtual GroupBox GroupBox1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._GroupBox1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._GroupBox1 = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label10
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label10;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label10 = value;
            }
        }

        internal virtual Label Label13
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label13;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label13 = value;
            }
        }

        internal virtual TextBox TxtDienGiai
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtDienGiai;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtDienGiai = value;
            }
        }

        internal virtual C1NumericEdit txtHeSo
        {
            [DebuggerNonUserCode]
            get
            {
                return this._txtHeSo;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._txtHeSo = value;
            }
        }
    }
}

